#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>

using namespace std;

void PrintPend(sigset_t& set)
{
    for(int signo = 31; signo >= 1; signo--)
    {
        if(sigismember(&set, signo)) cout << 1;
        else cout << 0;
    }
    cout << endl;
}
void header(int sig)
{
    sigset_t set;
    sigemptyset(&set);
    while(1)
    {
        sigpending(&set);
        PrintPend(set);
        sleep(1);
    }
}
int main()
{
    struct sigaction act,oact;
    memset(&act, 0, sizeof(act));
    memset(&oact, 0, sizeof(oact));
    sigaddset(&act.sa_mask, 3);
    sigaddset(&act.sa_mask, 4);
    sigaddset(&act.sa_mask, 5);
    act.sa_handler = header;
    sigaction(SIGINT, &act, &oact);

    while(1)
    {
        cout << "process running:" << getpid() << endl;
        sleep(1);
    }
    return 0;
}